package com.note.common.domain;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * 协作参与者实体类
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("collaboration_participant")
@Schema(description = "协作参与者实体")
public class CollaborationParticipant extends BaseEntity {
    
    /**
     * 记录ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "记录ID", example = "1")
    private Long id;
    
    /**
     * 会话ID
     */
    @TableField("session_id")
    @Schema(description = "会话ID", example = "1")
    private Long sessionId;
    
    /**
     * 用户ID
     */
    @TableField("user_id")
    @Schema(description = "用户ID", example = "1")
    private Long userId;
    
    /**
     * 角色：0-查看者，1-编辑者，2-管理员
     */
    @TableField("role")
    @Schema(description = "角色：0-查看者，1-编辑者，2-管理员", example = "1")
    private Integer role;
    
    /**
     * 参与者颜色（十六进制颜色代码）
     */
    @TableField("color")
    @Schema(description = "参与者颜色", example = "#FF5733")
    private String color;
    
    /**
     * 是否在线：0-离线，1-在线
     */
    @TableField("is_online")
    @Schema(description = "是否在线：0-离线，1-在线", example = "1")
    private Integer isOnline;
    
    /**
     * 光标位置（JSON格式）
     */
    @TableField("cursor_position")
    @Schema(description = "光标位置", example = "{\"line\":10,\"ch\":15}")
    private String cursorPosition;

    @Column(name = "created_at")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 修正月份MM和小时HH的大小写
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") // 修正时区写法
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    @Schema(description = "创建时间", example = "2023-10-01T12:00:00")
    private LocalDateTime createdAt;

    @Column(name = "updated_at")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") // 修正月份MM和小时HH的大小写
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") // 修正时区写法
    @TableField(value = "updated_at", fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "更新时间", example = "2023-10-01T12:00:00")
    private LocalDateTime updatedAt;
} 